#!/bin/bash
sleep 50s
sudo apt-get update
sudo apt install -y git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less
sudo useradd -m -d /opt/odoo13 -U -r -s /bin/bash odoo13
sudo apt-get install -y postgresql
sudo wget https://solution-as-code-publicbucket.obs.cn-north-4.myhuaweicloud.com/odoo/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt-get install -y ./wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo su - odoo13 <<EOF
git clone https://gitee.com/mirrors/odoo.git --depth 1 --branch 13.0 /opt/odoo13/odoo
cd /opt/odoo13
python3 -m venv odoo-venv
source odoo-venv/bin/activate
pip3 install wheel
pip3 install -r odoo/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
deactivate
mkdir /opt/odoo13/odoo-custom-addons
exit
EOF
echo "[options]" >> /etc/odoo13.conf
echo "; This is the password that allows database operations:" >> /etc/odoo13.conf
echo "admin_passwd = my_admin_passwd" >> /etc/odoo13.conf
echo "db_host = $1" >> /etc/odoo13.conf
echo "db_port = 5432" >> /etc/odoo13.conf
echo "db_user = odoo13" >> /etc/odoo13.conf
echo "addons_path = /opt/odoo13/odoo/addons,/opt/odoo13/odoo-custom-addons" >> /etc/odoo13.conf
sudo su - odoo13 <<EOF
nohup /opt/odoo13/odoo-venv/bin/python3 /opt/odoo13/odoo/odoo-bin -c /etc/odoo13.conf --db_password $2 --logfile /opt/odoo13/logs/ &
exit
EOF